package com.anti_poverty_detection_system.springboot.service.impl;

import com.anti_poverty_detection_system.springboot.model.IdentificationCodes;
import com.anti_poverty_detection_system.springboot.mapper.IdentificationCodesMapper;
import com.anti_poverty_detection_system.springboot.service.IIdentificationCodesService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ZITONG BAI
 * @since 2024-06-17
 */
@Service
public class IdentificationCodesServiceImpl extends ServiceImpl<IdentificationCodesMapper, IdentificationCodes> implements IIdentificationCodesService {

    @Autowired
    IdentificationCodesMapper identificationCodesMapper;
    @Override
    public Page<IdentificationCodes> getIdentificationCodes(Page<IdentificationCodes> identificationCodesPage){
        return identificationCodesMapper.selectPage(identificationCodesPage,null);
    }
    @Override
    public Page<IdentificationCodes> getSearchIdentificationCodes(Page<IdentificationCodes> identificationCodesPage,String keywords){
        return identificationCodesMapper.selectSearchIdentificationCodes(identificationCodesPage,keywords);
    }

    @Override
    public IdentificationCodes getIdentificationCodesByCode(String code){
        QueryWrapper<IdentificationCodes> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("code",code);
        return identificationCodesMapper.selectOne(queryWrapper);
    }
}
